import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:provider_demo/model/somemodel.dart';
import 'package:provider_demo/model_rating_bar.dart';
import 'package:provider_demo/model_rating_bar_consumer.dart';

class ProviderBaseExampleSolutionWithConsumer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Consumer<SomeModel>(
      builder: (context, model, widget) {
        return Scaffold(
          body: Center(
            child: Card(
              margin: EdgeInsets.all(50),
              elevation: 4,
              child: Padding(
                padding: const EdgeInsets.all(16),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      model.name,
                      style: TextStyle(
                          fontWeight: FontWeight.w800,
                          fontSize: 28,
                          color: Colors.black),
                    ),
                    Text(
                      model.address,
                      style: TextStyle(
                          fontSize: 24,
                          height: 1.5,
                          color: Colors.grey,
                          fontWeight: FontWeight.normal),
                    ),
                    SizedBox(
                      height: 20,
                    ),
                    ModelRatingBarConsumer(),
                    SizedBox(
                      height: 20,
                    ),
                    Container(
                      constraints:
                          BoxConstraints.loose(Size(double.infinity, 30)),
                      child: ListView.separated(
                          scrollDirection: Axis.horizontal,
                          shrinkWrap: true,
                          itemBuilder: (context, index) {
                            return Padding(
                              padding:
                                  const EdgeInsets.symmetric(horizontal: 5),
                              child: Container(
                                padding: const EdgeInsets.symmetric(
                                    vertical: 4, horizontal: 16),
                                decoration: BoxDecoration(
                                    border: Border.all(
                                        color: Colors.grey, width: 1),
                                    borderRadius:
                                        BorderRadius.all(Radius.circular(20))),
                                child: Text(
                                  model.features[index],
                                  style: TextStyle(
                                      fontSize: 14, color: Colors.grey),
                                ),
                              ),
                            );
                          },
                          separatorBuilder: (context, index) {
                            return Divider(
                              height: 1,
                            );
                          },
                          itemCount: model.features.length),
                    )
                  ],
                ),
              ),
            ),
          ),
        );
      },
    );
  }
}
